<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../../global/css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./frm.css" />
</head>
<body>
<div id="main">
    <div id="common-msg-block">
        <div id="setting-list" class="aui-list aui-media-list">
            <!--<div class="aui-list-header section-header">提醒方式</div>-->
            <!--<div class="aui-list-item">-->
                <!--<div class="aui-list-item-inner" style="display: flex;">-->
                    <!--<div class="aui-list-item-title">-->
                        <!--<div class="msg-setting-title">系统通知</div>-->
                        <!--<div class="msg-setting-desc">开启后24小时内将不接收应用内通知，24小时后自动关闭</div>-->
                    <!--</div>-->
                    <!--<div class="aui-list-item-right">-->
                        <!--<input type="checkbox" class="aui-switch" checked="">-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
        </div>
    </div>
</div>
<div id="no-msg" class="aui-hidex">
    <p>这里静悄悄 ^v^</p>
</div>
</body>

<script id="tpl-setting-item" type="text/x-dot-template">
    {{~it.array :data:section}}
    <div class="aui-list-header section-header">{{=data.title}}</div>
        {{~data.list :dict:row}}
            <div class="aui-list-item">
                <div class="aui-list-item-inner" style="display: flex;">
                    <div class="aui-list-item-title">
                        <div class="msg-setting-title">{{=dict.item}}</div>
                        <div class="msg-setting-desc {{=(dict.desc && dict.desc.length > 0) ? '' : 'aui-hide'}}">{{=dict.desc}}</div>
                    </div>
                    <div class="aui-list-item-right">
                        <input type="checkbox" class="aui-switch" data-section="{{=section}}" data-row="{{=row}}"
                               {{=(dict.value==1)?'checked':''}} onchange="checkBoxAction(this);">
                    </div>
                </div>
            </div>
        {{~}}
    {{~}}
</script>

<script type="text/javascript" src="../../../config.js"></script>
<script type="text/javascript" src="../../../global/script/lib/api.js"></script>
<script type="text/javascript" src="../../../global/script/lib/doT.min.js"></script>
<script type="text/javascript" src="../../../global/script/libx/myBadge.js"></script>
<script type="text/javascript" src="../../../global/script/libx/dateUtil.js"></script>
<script type="text/javascript" src="../../../global/script/lib/zepto.min.js"></script>
<script type="text/javascript" src="../../../global/script/lib/aui-lazyload.js"></script>
<script type="text/javascript" src="../../../global/script/mylib.js"></script>
<script type="text/javascript" src="../../../app.js"></script>
<script type="text/javascript" src="./frm.js"></script>

</html>


<script type="text/javascript" src="../../../global/script/globeAsyncList.js"></script>
<script type="text/javascript">
    window.asyncList = new asyncList();

    var json = {
        "status": 200,
        "msg": "ok",
        "data": [{
            "title": "提醒项",
            "list": [{
                "key": "sys_msg",
                "value": 1,
                "item": "系统通知"
            }, {
                "key": "im_msg",
                "value": 1,
                "item": "私聊"
            }, {
                "key": "reply",
                "value": 1,
                "item": "被评论"
            }, {
                "key": "recommend",
                "value": 1,
                "item": "被点赞"
            }, {
                "key": "topline",
                "value": 1,
                "item": "今日头条"
            }]
        }, {
            "title": "提醒方式",
            "list": [{
                "value": 0,
                "key": "not_at_night",
                "item": "夜间免打扰",
                "desc": "22:00-8:00间不接收通知"
            }, {
                "value": 0,
                "key": "not_in_24hours",
                "item": "24小时免打扰",
                "desc": "开启后24小时内将不接收应用内通知，24小时后自动关闭"
            }]
        }]
    };

    settingList = [];
    if (json.data && json.data.length > 0) {
        settingList = json.data;
    }
    var html = doT_Render2($api.byId('tpl-setting-item').innerHTML, {array: settingList});
    var convList = $api.byId('setting-list');
    $api.append(convList, html);

    if (settingList.length > 0) {
        rmNoMsgTips();
    }

    var q = {
        action:'notification_settings',
        'do': 'set'  // get为获取消息设置，set为提交消息设置
    };

    var changeObj = {sys_msg: 1};
    var data = {
        key: 'msg_setting_set_notification_setting',
        delay: 3000,
        method: 'ajax_post_with_query',
        params:['wuchen/api/user.php', q, changeObj],
        success: 'msg_setting_set_notification_setting_success'
    };

    window.asyncList.pushCache(data);

    // addCacheRequest();
    // function addCacheRequest() {
    //     window.asyncList.pushCache(data);
    //     setTimeout(function () {
    //         addCacheRequest();
    //     }, 2000);
    // }


</script>